/* 
 * File:   FiltreFlou.cpp
 * Author: dang
 * 
 * Created on 6 juin 2010, 15:08
 */

#include "FiltreFlou.h"
#include <iostream>

FiltreFlou::FiltreFlou()
: Filtre("Filtre Flou"){
}

FiltreFlou::~FiltreFlou() {
}

void
FiltreFlou::compute(SDL_Surface* area, const unsigned int x, const unsigned int y) const
{
    Uint32 color = 0;//FractalPrinter::getpixel(area, x,y);
    int n = 0;
    int xx = x;
    int yy = y;
    int k;
    int l;
    if (x > area->w || y > area->h)
        return ;
    for (k = xx - 5; k < (xx + 5); ++k)
    {
        if (k >= 0 && k < area->w)
        {
            for (l = yy - 5; l < (yy + 5); ++l)
            {
                if(l >= 0 && l < area->h)
                {
                    color += FractalPrinter::getpixel(area, k, l);
                    n++;
                }
            }
        }
    }
    //composition = (red + green + blue) / 3;
    color = color / n;
    FractalPrinter::putpixel(area, x, y, color);
}